<?
	include_once('header.php');

	include_once('sidebar.php');

	$edit = $_GET['edit'];
	$offset = $_GET['offset'];
	$limit = $_GET['limit'];
	$action = $_GET['action'];
	if(!$offset) { $offset = "0"; }
	if(!$limit) { $limit = "20"; }
	$new_post = $_POST['new_post'];
	$delete = $_GET['delete'];
	$update_options = drizzo_update_options();
?>

		<div id="main">

<?
	if($update_options == 2) {
		echo "\t\t\t\t<p class=\"save\">Options have been updated.</p>";
	} elseif($update_options == 1) {
		echo "\t\t\t\t<p class=\"alert\">Options could not be updated.</p>";
	}
?>			
			<h2><? if($_GET['options'] == 'theme_options') { $theme_meta = drizzo_theme_info(); echo $theme_meta['theme'] . " "; } elseif($_GET['options']) { echo ucwords(str_replace('_', ' ', $_GET['options'])) . " "; } else { echo "General "; } ?>Options</h2>
			
				<form name="options_form" id="options_form" action="" method="post">
<?
	if(!$_GET['options']) { // General Options
?>
					<label for="site_name">Site Name</label> <input type="text" name="site_name" value="<? echo drizzo_global_options("site_name"); ?>" /><br class="clear" />
					<label for="site_description">Site Description</label> <input type="text" name="site_description" value="<? echo drizzo_global_options("site_description"); ?>" /><br class="clear" />
					<label for="use_permalinks">Use Permalinks<a href="javascript:void(0)">?<span class="explain">Permalinks make your URLs appear as a series of folders (ie, http://drizzoblog.com/blog/welcome). If turned off your URLs will be in the form of 'http://drizzoblog.com/?id=1'.</span></a></label> <select name="use_permalinks">
						<option value="1"<? if(drizzo_global_options("use_permalinks") == '1') { echo " selected"; } ?>>Yes</option>
						<option value="0"<? if(drizzo_global_options("use_permalinks") == '0') { echo " selected"; } ?>>No</option>
					</select><br class="clear" />
					<label for="admin_css">Admin Style</label><? echo drizzo_admin_styles_dropdown(); ?>
					<hr class="rule" />
					<h3>Time &amp; Date</h3>
					<label for="timezone_offset">Timezone<a href="javascript:void(0)">?<span class="explain">Select your timezone or the UTC offset for your area during Standard Time.</span></a></label> <? echo drizzo_timezones_dropdown(); ?><br class="clear" />
					<p>The Date and Time Formats use standard PHP date() function variables. <a href="http://us3.php.net/date" title="date() Documentation">Click here for date() documentation.</a></p>
					<label for="time_format">Time Format</label> <input type="text" name="time_format" value="<? echo drizzo_global_options("time_format"); ?>"><br class="clear" />
					<label for="sample_time">Sample Time Output</label> <strong><? echo date(drizzo_global_options("time_format")); ?></strong> (Save Options to update)<br class="clear" />
<?
	} elseif($_GET['options'] == 'modules') { // Modules Options
?>
					<p>Select which modules you want to enable. (Note that not all modules have been implemented yet.)</p>
<?
		$modules = array('blog','pages','comments','podcasts','reviews','events','gallery','media','links');
		foreach($modules as $module) {
			$field = "module_" . $module;
?>
					<label for="<? echo $field; ?>"><? echo ucwords($module); ?></label> <select name="<? echo $field; ?>"><option value="1"<? if(drizzo_global_options($field) == 1) { echo " selected"; } ?>>On</option><option value="0"<? if(drizzo_global_options($field) == 0) { echo " selected"; } ?>>Off</option></select><br class="clear" />
<?
		}
	} elseif($_GET['options'] == 'cache') {
?>
					<label for="use_cache">Use Cache<a href="javascript:void(0)">?<span class="explain">If turned on, Drizzo will create static copies of visited pages and serve them to decrease server load.</span></a></label> <select name="use_cache"><option value="1"<? if(drizzo_global_options('use_cache') == 1) { echo " selected"; } ?>>On</option><option value="0"<? if(drizzo_global_options('use_cache') == 0) { echo " selected"; } ?>>Off</option></select><br class="clear" />
					<label for="cache_type">Cache Type<a href="javascript:void(0)">?<span class="explain">If set to 'Always', Drizzo will use any available cache file if it is not older than the Expire Time. If set to 'Progressive', Drizzo will only serve cached content when the server load average is above the Server Load Limit.</span></a></label> <select name="cache_type"><option value="always"<? if(drizzo_global_options('cache_type') == 'always') { echo " selected"; } ?>>Always</option><option value="progressive"<? if(drizzo_global_options('cache_type') == 'progressive') { echo " selected"; } ?>>Progressive</option></select><br class="clear" />
					<label for="cache_time">Cache Expire Time<a href="javascript:void(0)">?<span class="explain">How many minutes Drizzo should keep a cache file before updating it.</span></a></label> <input type="text" name="cache_time" value="<? echo drizzo_global_options('cache_time'); ?>" /><br class="clear" />
					<label for="cache_time">Server Load Limit<a href="javascript:void(0)">?<span class="explain">The number Drizzo will compare the server load to to determine whether to serve cached content when Cache Type is set to Progressive. If you find that your server is getting overworked, use a lower number.</span></a></label> <input type="text" name="cache_server_load" value="<? echo drizzo_global_options('cache_server_load'); ?>" /><br class="clear" />
<?		
	} elseif($_GET['options'] == 'post') { // Posts Options
?>
					<label for="posts_per_page">Posts per page</label><input type="text" name="posts_per_page" value="<? echo drizzo_global_options("posts_per_page"); ?>" /><br class="clear" />
					<label for="use_excerpts">Content Length on Indexes<a href="javascript:void(0)">?<span class="explain">Should Drizzo display the full content or an excerpt of each post on pages with multiple posts</span></a></label> <select name="use_excerpts"><option value="1"<? if(drizzo_global_options('use_excerpts') == 1) { echo " selected"; } ?>>Excerpt</option><option value="0"<? if(drizzo_global_options('use_excerpts') == 0) { echo " selected"; } ?>>Full Length</option></select><br class="clear" /><br class="clear" />
					<h3>Text Conversions</h3>
					<label for="smartypants">Use Smart Quotes<a href="javascript:void(0)">?<span class="explain">If this option is turned on, quotation marks (single and double) will be converted to their curly equivalents &#8220;,&#8221;,&#8216; and &#8217;.</span></a></label> <select name="smartypants"><option value="1"<? if(drizzo_global_options('smartypants') == 1) { echo " selected"; } ?>>Yes</option><option value="0"<? if(drizzo_global_options('smartypants') == 0) { echo " selected"; } ?>>No</option></select><br class="clear" /><br class="clear" />
					<label for="autolinks">Use Automatic Links<a href="javascript:void(0)">?<span class="explain">If this option is turned on, any phrase matching the title of a link in your links list will be converted to a link.</span></a></label> <select name="autolinks"><option value="1"<? if(drizzo_global_options('autolinks') == 1) { echo " selected"; } ?>>Yes</option><option value="0"<? if(drizzo_global_options('autolinks') == 0) { echo " selected"; } ?>>No</option></select><br class="clear" />
					<label for="autolinks">Case Sensitive Automatic Links<a href="javascript:void(0)">?<span class="explain">If this option is turned on, links will only be created when the phrase is exactly the same as the title in the links list. (IE, Drizzo will only match 'Drizzo' and not 'drizzo')</span></a></label> <select name="autolinks_case_sensitive"><option value="1"<? if(drizzo_global_options('autolinks_case_sensitive') == 1) { echo " selected"; } ?>>Yes</option><option value="0"<? if(drizzo_global_options('autolinks_case_sensitive') == 0) { echo " selected"; } ?>>No</option></select><br class="clear" />
					<label for="autolinks_all">Convert Which Autolink Matches<a href="javascript:void(0)">?<span class="explain">'All' means every match will be converted while 'First' only converts the first occurrence.</span></a></label> <select name="autolinks_all"><option value="1"<? if(drizzo_global_options('autolinks_all') == 1) { echo " selected"; } ?>>All</option><option value="0"<? if(drizzo_global_options('autolinks_all') == 0) { echo " selected"; } ?>>First</option></select><br class="clear" />
					<hr class="rule" />
					<h3>Social Network Links</h3>
					<p>Select which Social Network Links you would like to be include in drizzo_social_links().</p>
					<label for="social_link_digg">Digg.com</label> <select name="social_link_digg"><option value="1"<? if(drizzo_global_options('social_link_digg') == 1) { echo " selected"; } ?>>Yes</option><option value="0"<? if(drizzo_global_options('social_link_digg') == 0) { echo " selected"; } ?>>No</option></select><br class="clear" />
					<label for="social_link_digg_size">Digg.com Button Size</label> <select name="social_link_digg_size"><option value="normal"<? if(drizzo_global_options('social_link_digg_size') == 'normal') { echo " selected"; } ?>>Normal</option><option value="compact"<? if(drizzo_global_options('social_link_digg_size') == 'compact') { echo " selected"; } ?>>Compact</option></select><br class="clear" />
					<hr class="rule" />
					<h3>Allow PHP content in posts to be executed?</h3>
					<p>This can be very dangerous for sites with multiple users.</p>
					<label for="allow_eval">Allow eval()?</label> <select name="allow_eval"><option value="1"<? if(drizzo_global_options('allow_eval') == 1) { echo " selected"; } ?>>Yes</option><option value="0"<? if(drizzo_global_options('allow_eval') == 0 || !drizzo_global_options('allow_eval')) { echo " selected"; } ?>>No</option></select><br class="clear" />
					<hr class="rule" />
					<h3>Ping Blog Services</h3>
					<p>You can have Drizzo automatically notify any of the following blog indexes whenever you publish or edit an item.  Check the ones you want to use.</p>
<?
		$ping_services_lookup = @mysql_query("SELECT `value` FROM `$drizzo_options` WHERE `name`='ping_service'");
		$checked = array();
		if(!mysql_errno()) {
			while($service = @mysql_fetch_assoc($ping_services_lookup)) {
				$checked[] = $service['value'];
			}
		}
		$services = array('weblogscom' => 'Weblogs.com','blogs' => 'Blo.gs','technorati' => 'Technorati','feedburner' => 'FeedBurner','syndic8' => 'Syndic8','newsgator' => 'Newsgator','feedster' => 'Feedster','myyahoo' => 'My Yahoo!','pubsubcom' => 'PubSub','blogdigger' => 'Blogdigger','blogrolling' => 'BlogRolling','blogstreet' => 'BlogStreet','moreover' => 'Moreover','weblogalot' => 'Weblogalot','icerocket' => 'Ice Rocket','newsisfree' => 'News Is Free','topicexchange' => 'Topic Exchange');
		foreach($services as $value => $name) {
			if(array_search($value,$checked) !== false) {
				echo "<span class=\"checkbox_wrap\"><input type=\"checkbox\" class=\"checkbox\" name=\"ping_service[]\" value=\"$value\" checked />$name</span>";
			} else {
				echo "<span class=\"checkbox_wrap\"><input type=\"checkbox\" class=\"checkbox\" name=\"ping_service[]\" value=\"$value\" />$name</span>";
			}
		}
?>
					<br class="clear" />
<?
	} elseif($_GET['options'] == 'warehouse') { // Warehouse Options
?>
					<label for="warehouse_use">Use the Warehouse<a href="javascript:void(0)">?<span class="explain">If enabled, the Warehouse will store previous revisions of all posts up to the number of revisions specified below.  These revisions can then be restored at a later time.</span></a></label> <select name="warehouse_use"><option value="1"<? if(drizzo_global_options('warehouse_use') == "1") { echo " selected"; } ?>>Yes</option><option value="0"<? if(drizzo_global_options('warehouse_use') == "0") { echo " selected"; } ?>>No</option></select><br class="clear" />
					<label for="warehouse_limit">Warehouse Limit<a href="javascript:void(0)">?<span class="explain">The number of previous revisions to store in the Warehouse if the Use Warehouse option is enabled.</span></a></label> <input type="text" name="warehouse_limit" value="<? echo drizzo_global_options('warehouse_limit'); ?>" /><br class="clear" />
<?
	} elseif($_GET['options'] == 'comments') { // Comments Options
		
	} elseif($_GET['options'] == 'theme') { // Theme Options
		$theme = drizzo_global_options("theme");
		$theme_info = drizzo_theme_info();
?>
					<h3>Current Theme</h3>
					<div class="theme_thumb" id="theme_thumb_selected">
						<a href="javascript:void(0);" onclick="$('theme_thumb_selected').id = '';$(this).parentNode.id = 'theme_thumb_selected';document.options_form.theme_input.value = '<? echo $theme; ?>';" title="Select This Theme"><img src="<? echo $theme_info['screenshot']; ?>" alt="Theme Preview" width="300" height="170" />
						<p><strong><? echo $theme_info['theme'] . " " . $theme_info['version']; ?></strong><br />
						<em>Author:</em> <? echo $theme_info['author']; ?><br />
						<em>URL:</em> <? echo $theme_info['url']; ?><br />
						<em>Description:</em> <? echo $theme_info['description']; ?></p></a>
					</div>
					<input type="hidden" name="theme" value="<? echo $theme; ?>" id="theme_input" />
					<br class="clear" />
					<div class="rule"></div>
					<h3>Available Themes <em>(Click to select)</em></h3>
<?
		$themes_list = drizzo_list_valid_themes();
		if($themes_list) {
			foreach($themes_list as $themes) {
?>
					<div class="theme_thumb" id="">
						<a href="javascript:void(0);" onclick="$('theme_thumb_selected').id = '';$(this).parentNode.id = 'theme_thumb_selected';document.options_form.theme_input.value = '<? echo $themes['nicename']; ?>';" title="Select This Theme"><img src="<? echo $themes['screenshot']; ?>" alt="Theme Preview" width="300" height="170" />
						<p><strong><? echo $themes['theme'] . " " . $themes['version']; ?></strong><br />
						<em>Author:</em> <? echo $themes['author']; ?><br />
						<em>URL:</em> <? echo $theme_info['url']; ?><br />
						<em>Description:</em> <? echo $theme_info['description']; ?></p></a>
					</div>
<?
			}
		} else {
			echo "<p>There are no valid themes available.</p>";
		}
		$invalid_themes = drizzo_list_invalid_themes();
		if($invalid_themes) {
?>
					<br class="clear" />
					<div class="rule"></div>
					<h3>Partial Themes</h3>
<?
			foreach($invalid_themes as $invalid_theme) {
?>
					<p class="invalid_theme"><strong><? echo $invalid_theme['theme']; ?></strong> <? echo $invalid_theme['error']; ?></p>
<?
			}
		}
	} elseif($_GET['options'] == 'theme_options') {
		if(drizzo_theme_options(drizzo_global_options('theme'))) {
			include(root_dir . "drizzo-addons/themes/" . drizzo_global_options('theme') . "/_options.php");
		} else {
			echo "<p class=\"alert\">This theme has no options.</p>\n";
		}
	} elseif($_GET['options'] == 'gallery') {
?>
					<label for="gallery_basename">URL Base for Gallery<a href="javascript:void(0)">?<span class="explain">If you want to use a custom folder name as the base of the gallery, enter it here. (IE, '/portfolio/album/image' instead of '/gallery/album/image'.) Please leave off the leading and trailing /'s.</span></a></label> <input type="text" name="gallery_basename" value="<? echo drizzo_global_options('gallery_basename');?>" /><br class="clear" />
					<label for="lightbox_gallery">Use Lightbox.js for Gallery<a href="javascript:void(0)">?<span class="explain">If you would like to use Lightbox to present your gallery instead of having images load on their own page, enable this option.</span></a></label> <select name="gallery_lightbox"><option value="0"<? if(drizzo_global_options('gallery_lightbox') == 0) { echo " selected";} ?>>No</option><option value="1"<? if(drizzo_global_options('gallery_lightbox') == 1) { echo " selected";} ?>>Yes</option></select><br class="clear" />
					<label for="gallery_thumb_width">Default Thumbnail Width (in pixels)</label> <input type="text" name="gallery_thumb_width" value="<? echo drizzo_global_options('gallery_thumb_width')?>" /><br class="clear" />
					<label for="gallery_thumb_height">Default Thumbnail Height (in pixels)</label> <input type="text" name="gallery_thumb_height" value="<? echo drizzo_global_options('gallery_thumb_height')?>" /><br class="clear" />
<?
	} elseif($_GET['options'] == 'events') {
?>
					<label for="events_basename">URL Base for Events<a href="javascript:void(0)">?<span class="explain">If you want to use a custom folder name as the base of events, enter it here. (IE, '/dates/event-title' instead of '/events/event-title'.) Please leave off the leading and trailing /'s.</span></a></label> <input type="text" name="events_basename" value="<? echo drizzo_global_options('events_basename')?>" /><br class="clear" />
					<label for="events_default">Default Events View</label>	<select name="events_default"><option value='table'>Calendar Month</option><option value='list'>List</option></select><br class="clear" />
<?
	} elseif($_GET['options'] == 'media') {
		if(ini_get('safe_mode')) {
?>
					<h3>FTP</h3>
					<label for="ftp_connect">FTP URL<a href="javascript:void(0)">?<span class="explain">The URL of your site's FTP connection. Typically <em>ftp.yourdomain.com</em>.</span></a></label> <input type="text" name="ftp_connect" value="<? echo drizzo_global_options('ftp_connect'); ?>" id="ftp_connect" /><br class="clear" />
					<label for="ftp_connect">FTP Username</label> <input type="text" name="ftp_user" value="<? echo drizzo_global_options('ftp_user'); ?>" id="ftp_user" /><br class="clear" />
					<label for="ftp_pass">FTP Password</label> <input type="password" name="ftp_pass" value="<? echo drizzo_global_options('ftp_pass'); ?>" id="ftp_pass" /><br class="clear" />
					<hr class="rule" />
<?			
		}
	} elseif($_GET['options'] == 'miscellaneous') { // Miscellaneous Options
		
	} else { // Unsupported Options
?>
					<p>This Options module is not yet supported.</p>
<?
	}
?>			
					<br class="clear" />
					<p class="center"><input type="submit" class="submit" name="submit" value="Save Options" /></p>
				</form>

			<br class="clear" />
			
		</div>
<?
	include_once('footer.php');
?>
